package com.home.databinding2

import android.util.Log
import androidx.databinding.BaseObservable
import androidx.databinding.Bindable

class TwoWayBindingViewModel() : BaseObservable() {
    private var mydata:MyData? = null

    @Bindable
    fun getPwd():String? {
        Log.e("zzm debug","getPwd:"+mydata?.pwd)
        return mydata?.pwd
    }
    fun setPwd(str:String){
        Log.e("zzm debug","setPwd：$str")
        if(str != mydata?.pwd){
            mydata?.pwd = str
            notifyPropertyChanged(BR.pwd)
        }else{
            Log.e("zzm debug","setPwd null")
        }
    }

    @Bindable
    fun getUserName():String? {
        Log.e("zzm debug","getUserName:"+mydata?.userName)
        return mydata?.userName
    }
    fun setUserName(str:String){
        Log.e("zzm debug","setUserName:$str")
        if(str != mydata?.userName){
            mydata?.userName = str
            notifyPropertyChanged(BR.userName)
        }else{
            Log.e("zzm debug","setUserName null")
        }
    }


}